#import "dfhgwhruebvhrheyinvalidoutput.h"
@interface dfhgwhruebvhrheyinvalidoutput ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tabIV;
@end
static NSString *cellIdentifier = @"SPP_AuthEmailExtendViewCell";
@implementation dfhgwhruebvhrheyinvalidoutput {
	NSArray *suffixList;
	CGFloat(^_height)(void);
	NSMutableArray *dataArray;
	void(^_selected)(NSString *content);
}
- (instancetype)initWithFrame:(CGRect)frame {
	if (self = [super initWithFrame:frame]) {
		[self setUI];
	}
	return self;
}
- (void)setUI {
	dataArray = [@[] mutableCopy];
	self.backgroundColor = [UIColor whiteColor];
	suffixList = @[@"@gmail.com", @"@hotmail.com", @"@yahoo.com", @"@aol.com", @"@outlook.com"];
	self.tabIV = [[UITableView alloc] init];
	self.tabIV.delegate = self;
	self.tabIV.dataSource = self;
	self.tabIV.scrollEnabled = NO;
	self.tabIV.separatorInset = UIEdgeInsetsZero;
	self.tabIV.backgroundColor = [UIColor clearColor];
	[self.tabIV registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier];
	[self addSubview:self.tabIV];
}
- (void)inputText:(NSString *)text withViewHeight:(void(^)(CGFloat height))height andSelected:(void(^)(NSString *select))click {
	_selected = click;
	[dataArray removeAllObjects];
	NSArray<NSString *> *splits = [text componentsSeparatedByString:@"@"];
	for (NSString *suffix in suffixList) {
		if (splits.count < 2) {
			[dataArray addObject:[NSString stringWithFormat:@"%@%@",text, suffix]];
		}else {
			if([splits lastObject].length == 0) {
				[dataArray addObject:[NSString stringWithFormat:@"%@%@",[splits firstObject], suffix]];
			}else {
				if ([suffix rangeOfString:[splits lastObject]].location != NSNotFound) {
					[dataArray addObject:[NSString stringWithFormat:@"%@%@",[splits firstObject], suffix]];
				}
			}
		}
	}
	self.layer.cornerRadius = 10;
	self.layer.borderWidth = 0.5;
	self.php_h = 44 * dataArray.count;
	self.layer.borderColor = @"#333333".dhgfywegwygeydwlearneddesignate.CGColor;
	[self.tabIV reloadData];
	if (height) {
		height(self.php_h);
	}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	NSString *content = dataArray[indexPath.row];
	if(_selected) {
		_selected(content);
	}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	return dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
	cell.selectionStyle = UITableViewCellSelectionStyleNone;
	cell.textLabel.textColor = @"#3B414B".dhgfywegwygeydwlearneddesignate;
	cell.textLabel.text = dataArray[indexPath.row];
	cell.backgroundColor = [UIColor clearColor];
	return cell;
}
- (void)layoutSubviews {
	[super layoutSubviews];
	[self.tabIV mas_makeConstraints:^(MASConstraintMaker *make) {
		make.edges.equalTo(self);
	}];
}
@end
